// pages/lostAndFound/index.js
import { request } from "../../request/index.js";
import regeneratorRuntime from "../../lib/runtime/runtime";

Page({
  /**
   * 页面的初始数据
   */
  data: {
    tabs: [{ id: 0, value: "失物招领", isActive: true }],
    foundList: [],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getFoundData();
  },

  //获取失物招领数据列表
  async getFoundData() {
    const res = await request({ url: "/lastfound/findAllLastFound" });
    this.setData({ foundList: res.data.data });
  },

  //时间戳处理函数，时间戳转换成正常数据
  fromData(a) {
    let time = new Date(a);
    let month = time.getMonth() + 1;
    let date = time.getDate();
    let hours = time.getHours();
    let minutes = time.getMinutes();
    // let second = time.getSeconds() // 获取秒数
    // 小于10前加一个0
    if (month < 10) {
      month = "0" + month;
    }
    if (date < 10) {
      date = "0" + date;
    }
    return time.getFullYear() + "-" + month + "-" + date;
  },
});
